/*
 * @Date:  2024-05-25 14:06:59
 * @LastEditors: LDH 574427343@qq.com
 * @LastEditTime: 2023-03-29 15:52:57
 * @FilePath: src\api\workflow.js
 * 工作流 相关接口
 */
import Cookies from "js-cookie";
import request from "@/utils/request";
const headers = {
  Userid: Cookies.get("userId"),
  Username: Cookies.get("userName"),
};
/**
 * 获取流程配置详情
 * @param { * } data
 * @returns
 */
export function getApiWorkFlowData(data) {
  return request({
    url: `/bpmnConf/detail/${data.id}`,
    method: "get",
    headers: headers,
  });
}
/**
 * 获取DIY FromCode
 * @returns
 */
export function getDIYFromCodeData() {
  return request({
    url: "/bpmnBusiness/getDIYFormCodeList",
    method: "get",
    headers: headers,
  });
}

/**
 * 设置/添加审批流程配置详情
 * @param {*} data
 * @returns
 */
export function setApiWorkFlowData(data) {
  return request({
    url: "/bpmnConf/edit",
    method: "post",
    data: data,
    headers: headers,
  });
}
/**
 * 获取代办事项
 * @returns
 */
export function getTodoList() {
  return request({
    url: "/bpmnConf/todoList",
    method: "get",
    headers: headers,
  });
}

/**
 * 获取抄送给我流程列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getCopyToMelistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/process/listPage/9",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取所有实例列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getAllProcesslistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/process/listPage/6",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取用户代办数据列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getPenddinglistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/process/listPage/5",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取用户已审批数据列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getApprovedlistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/process/listPage/4",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取我发起的流程列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getMyRequestlistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/process/listPage/3",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取流程配置数据列表
 * @param {*} data
 * @returns
 */
export function getBpmnConflistPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    entity: taskMgmtVO,
  };
  return request({
    url: "/bpmnConf/listPage",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 审批,发起审批
 * @param {*} data
 * operationType 1 发起 2 重新提交 3 审批
 * @returns
 */
export function processOperation(data) {
  return request({
    url: `/bpmnConf/process/buttonsOperation?formCode=${data.formCode}`,
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取审批进度数据
 * @param { Number } id
 * @returns
 */
export function getBpmVerifyInfoVos(param) {
  return request({
    url: `/bpmnConf/getBpmVerifyInfoVos?processNumber=${param.processNumber}`,
    method: "get",
    headers: headers,
  });
}

/**
 * 流程预览
 * @param {*} param
 * @returns
 */
export function getFlowPreview(data) {
  return request({
    url: "/bpmnConf/startPagePreviewNode",
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 流程生效
 * @param {*} data
 * @returns
 */
export function getEffectiveBpmn(data) {
  return request({
    url: `/bpmnConf/effectiveBpmn/${data.id}`,
    method: "get",
    headers: headers,
  });
}

/**
 * 获取审批页面按钮权限
 * @param {*} data
 * @returns
 */
export function getViewBusinessProcess(data) {
  return request({
    url: `/bpmnConf/process/viewBusinessProcess?formCode=${data.formCode}`,
    method: "post",
    data: data,
    headers: headers,
  });
}

/**
 * 获取审批页面 审批人配置类型
 * @returns
 */
export function getApproveNodeProperties() {
  return request({
    url: "/bpmnBusiness/listNodeProperties",
    method: "get",
    headers: headers,
  });
}

/**
 * 获取委托列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getUserEntrustListPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnBusiness/entrustlist/1",
    method: "post",
    data: data,
    headers: headers,
  });
}
/**
 * 获取委托列表
 * @param {*} pageDto
 * @param {*} taskMgmtVO
 * @returns
 */
export function getEntrustListPage(pageDto, taskMgmtVO) {
  let data = {
    pageDto: pageDto,
    taskMgmtVO: taskMgmtVO,
  };
  return request({
    url: "/bpmnBusiness/entrustlist/2",
    method: "post",
    data: data,
    headers: headers,
  });
}
/**
 *  委托详情
 * @returns
 */
export function entrustDetail(id) {
  return request({
    url: `/bpmnBusiness/entrustDetail/${id}`,
    method: "get",
    headers: headers,
  });
}
/**
 * 设置委托
 * @returns
 */
export function setEntrust(data) {
  return request({
    url: "/bpmnBusiness/editEntrust",
    method: "post",
    data: data,
    headers: headers,
  });
}
/**
 * 获取流程自选审批人节点
 * @param {*} formCode
 * @returns
 */
export function getStartUserChooseModules(formCode) {
  return request({
    url: `/bpmnBusiness/getStartUserChooseModules?formCode=${formCode}`,
    method: "get",
    headers: headers,
  });
}
